<%--
  Created by IntelliJ IDEA.
  User: argentum
  Date: 2018/12/31
  Time: 20:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <!-- jsp文件头和头部 -->
    <%@ include file="../base/top.jsp"%>
    <title>课程资料列表</title>
</head>
<body class="no-skin">
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div class="hr hr-18 dotted hr-double"></div>
                <div class="row">
                    <div class="col-xs-12">
                        <div style="width: 100%;text-align: right">
                            <a id="upload" class="btn btn-xs btn-primary" style="text-align: right" title="云端导入"><i
                                    class="ace-icon fa fa-cloud"></i></a>
                        </div>
                        <table id="data-table" width="100%" class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>
                                    <input type="checkbox" id="check-all"/>
                                </th>
                                <th>序号</th>
                                <th>名称</th>
                                <th>日期</th>
                                <th>类型</th>
                                <th>大小</th>
                            </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                        <a class="btn btn-xs btn-primary"
                           id="load-all"
                           title="批量下载"><i
                                class="ace-icon fa fa-download bigger-140"></i></a>
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>
    </div>

    <%--<a href="material/Android_v9.pdf" class="downloadable">2</a>--%>
    <!-- /.main-content -->
    <!-- 返回顶部 -->
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
</div>


<form id="uploadForm">
    <input type="file" id="file" name="file"
           style="filter:alpha(opacity=0);opacity:0;width: 0;height: 0;"/>
</form>
<!-- /.main-container -->
<!-- basic scripts -->
<!-- 页面底部js¨ -->
<%@ include file="../base/foot.jsp"%>
<script type="text/javascript">
    $("#upload").click(function () {
        alert('云端导入');
        //触发 文件选择的click事件
//        $("#file").trigger("click");
    });
//    $("#file").change(function () {
//            alert('云端导入');
//        }
//    );
    $("#load-all").click(function () {
        var checked = getAllCheckedRowValue();
        for (var index = 0; index < checked.length; index++) {
            download(checked[index].courseMaterialName+checked[index].fileType, checked[index].courseMaterialAddress);
        }
    });

    var table = null;
    var url='material/search_all_course_material_files';
    var columnsData =  [
        {
            bSortable : false,
            className : "text-left",
            width : "50px",
            'data': 'courseMaterialId',
            render : function(data, type, row, meta) {
                return "<input type=\"checkbox\"/>";
            }
        },
        {
            bSortable : false,
            data: null,
            width : "40px",
            className: 'text-center whiteSpace',
            render:function(data,type,row,meta) {
                return meta.row + 1 +
                    meta.settings._iDisplayStart;
            }
        },
        {'data': 'courseMaterialName'},
        {'data': 'courseMaterialCreateTime'},
        {bSortable : false,'data': 'fileType'},
        {bSortable : false,'data': 'fileSize'}
    ];
    var dataBaseFiled =  [
        {
            data: null,
            bSortable : false,
            className : "text-left",
            width : "50px",
            render : function(data, type, row, meta) {
                return "<input type=\"checkbox\"/>";
            }
        },
        {
            bSortable : false,
            className : "text-left",
            width : "50px",
            render : function(data, type, row, meta) {
                return '"' + row.id + '"';
            }
        },
        {'data': 'course_material_name'},
        {'data': 'course_material_create_time'},
        {},{}
    ];
    $(document).ready(function() {
        table = $('#data-table').DataTable($.extend(true,{},CONSTANT.DATA_TABLES.DEFAULT_OPTION,{
            columns:columnsData,
            ajax: function (data,callback) {
                ajax(data,callback,dataBaseFiled,url);
            },
            order:[[ 2, "asc" ]]
        }));
    });
</script>

</body>
</html>